clear all
close all
symbl={'-';'--';'-.';':';'-';'--';'-.';':';'-'};
symb={'o','s','^','>','<','v','.','*','+'};
sig=[0.5 .39 .68 1.2 1.35]*10^-10;%angstrom
knot=[1 .95 .84 .19 .18];
force=[0:100]*10^-12;
figure2=figure('units','normalized','position',[0.15 .4 .6 .5],'Color',[1 1 1]);
hold on
for i=1:length(sig)
    plot(force*10^12,knot(i).*exp(sig(i).*force./(310.*1.38e-23)),'linestyle',char(symbl(i)),'color',((i)/10).*[1 1 1], 'linewidth', 3,'Marker','none');
end
legend('Case 1','Case 2','Case 3','Case 4','Case 5','Location','NorthWest')
set(gca,'FontSize',30);
set(gca,'position',[0.1893    0.2500    0.7157    0.68]);
grid on
xlabel('Force (pN)','FontSize',35);
ylabel({'Dissociation Rate', 'Constant(s^-^1)'},'FontSize',35);
% xlim([100 100000]);
ylim([0 5]);
% set(gca,'xscale','log');

n=1;
kr0=1;
ii=1;
t=[0:.1:10];
figure2=figure('units','normalized','position',[0.15 .4 .6 .5],'Color',[1 1 1]);
S=100;
    F=S*32.054*(.0038)*(3.8e-6)^2;
%     F=0;
%     F=20e-12;
    kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
Pnb=exp(-n*kr*t)
hold on
i=1;
plot(t,Pnb,'linestyle',char(symbl(i)),'color',((i)/10).*[1 1 1], 'linewidth', 3,'Marker','none');
tt=t;
for n=[2 5 10 100];
    i=i+1;
    ii=n-1;
    kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
    Pnb=exp(-n*kr*tt);
    tot=[Pnb ];
    
    
    while ii>=1
        kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
%         q=dsolve('Dy=(ii+1)*kr0*Pnbb-ii*kr0*y','y(0)=0');
        q=ode45(@(t,y) bonds(t,y,Pnb',ii,kr,tt),[0 max(tt)],[0]);
%         q=subs(q);
        Pnb=interp1(q.x,q.y,tt);
        tot=[tot;Pnb];

        ii=ii-1;
    end
%     tot=[tot;-(1./n).*exp(-n.*kr0.*t)];
    plot(t,sum(tot),'linestyle',char(symbl(i)),'color',((i)/10).*[1 1 1], 'linewidth', 3,'Marker','none');
end

ylim([0.01 1])
xlim([0 max(tt)]);
set(gca,'FontSize',30);
set(gca,'position',[0.1893    0.2500    0.7157    0.68]);
grid on
set(gca,'yscale','log');
xlabel('Time(s)','FontSize',35);
ylabel({'Fraction remaining', 'bound'},'FontSize',35);

legend('1 bond','2 bond','5 bond','10 bond','100 bond','Location','SouthWest')
% 
% syms('kr','i','tt','n')
% % syms('a','tt','i')
% p=simple((1/(i*kr0*tt))*int(i*kr0*tt*(i+1)*kr0*exp(-n*kr0*tt),tt)+a/(i*kr0*tt))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n=1;
kr0=1;
ii=1;
t=[0:.1:10];
kf0=1e5; %1/M-s
% kad=
figure2=figure('units','normalized','position',[0.15 .4 .6 .5],'Color',[1 1 1]);
S=600;
    F=S*32.054*(.0038)*(3.8e-6)^2;
%     F=0;
%     F=20e-12;
    kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
Pnb=exp(-n*kr*t)
hold on
i=1;
plot(t,Pnb,'linestyle',char(symbl(i)),'color',((i)/10).*[1 1 1], 'linewidth', 3,'Marker','none');
tt=t;
for n=[2 5 10 100];
    i=i+1;
    ii=n-1;
    kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
    Pnb=exp(-n*kr*tt);
    tot=[Pnb ];
    
    
    while ii>=1
        kr=kr0*exp((.5e-10)*F/(ii*310*1.38e-23));
%         q=dsolve('Dy=(ii+1)*kr0*Pnbb-ii*kr0*y','y(0)=0');
        q=ode45(@(t,y) bonds(t,y,Pnb',ii,kr,tt),[0 max(tt)],[0]);
%         q=subs(q);
        Pnb=interp1(q.x,q.y,tt);
        tot=[tot;Pnb];

        ii=ii-1;
    end
%     tot=[tot;-(1./n).*exp(-n.*kr0.*t)];
    plot(t,sum(tot),'linestyle',char(symbl(i)),'color',((i)/10).*[1 1 1], 'linewidth', 3,'Marker','none');
end

ylim([0.01 1])
xlim([0 max(tt)]);
set(gca,'FontSize',30);
set(gca,'position',[0.1893    0.2500    0.7157    0.68]);
grid on
set(gca,'yscale','log');
xlabel('Time(s)','FontSize',35);
ylabel({'Fraction remaining', 'bound'},'FontSize',35);

legend('1 bond','2 bond','5 bond','10 bond','100 bond','Location','SouthWest')